const path = require('path') //commJson规范

const htmlWebpackPlugin = require('html-webpack-plugin'); //只是引入
const htmlPlugin = new htmlWebpackPlugin({
    template: './src/index.html',
    filename: 'index.html'
})

const VueLoaderPlugin = require('vue-loader/lib/plugin')
const vuePlugin = new VueLoaderPlugin()

module.exports = {
    mode: 'development',
    entry: path.resolve(__dirname,'./src/js/main.js'), //入口，要求绝对路径
    output: {
        path: path.resolve(__dirname,'dist'),
        filename: 'bundle.js'
    },
    plugins: [htmlPlugin,vuePlugin],
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [ 'style-loader','css-loader' ]
            },
            {
                test: /\.(png|jpg|gif|jpeg)$/,
                use: [{
                    loader: 'url-loader',
                    options: {
                        limit: 800000
                    }
                }, 'file-loader']
            },
            {
                test: /\.js$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env']
                    }
                }
            },
            {
                test: /\.vue$/,
                use: 'vue-loader'
            }
        ]
    }
};